<?php

/**
* @author Petr Fort
*/

class Knihovna_Model_Ctenar
{

   public function vypisCtenare ($id) {
    $id = (int)$id;
    $row = $this->fetchRow('id =' . $id);
    if (!$row) {throw new Exception('Dle ID nelze nalezt');}
    return $row->toArray();
    }

    public function pridejCtenare ($id, $jmeno, $prijmeni, $narozeni) {
    $data = array(
        'jmeno' => $jmeno,
        'prijmeni' => $prijmeni,
        'narozeni' => $narozeni
    );
    $this->insert($data);
    }

    public function upravCtenare ($id, $jmeno, $prijmeni, $narozeni) {
    $data = array(
        'jmeno' => $jmeno,
        'prijmeni' => $prijmeni,
        'kontakt' => $narozeni
    );
    $this->update($data, 'id =' . (int)$id);
    }

    public function smazCtenare ($id){
    $this->delete('id =' . (int)$id);
    }


}

